package com.label.config;

import com.label.common.CommonResult;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestControllerAdvice
public class DefaultExceptionHandler {
    public CommonResult exceptionHandler(HttpServletRequest request, Exception ex){
        ex.printStackTrace();
        if(ex instanceof NoHandlerFoundException){
            return CommonResult.nohandler();
        }
        return CommonResult.failed(ex.getMessage());
    }
}
